home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / kgdb-4.5 / ds3100.md / gdb / coredep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-21  |  3.2 KB  |  106 lines

  1. /* Extract registers from a "standard" core file, for GDB.
  2.    Copyright (C) 1988-1991  Free Software Foundation, Inc.
  3.  
  4. This file is part of GDB.
  5.  
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. /* core.c is supposed to be the more machine-independent aspects of this;
  21.    this file is more machine-specific.  */
  22.  
  23. #include "defs.h"
  24. #include <sys/types.h>
  25. #include <sys/param.h>
  26. #include "gdbcore.h"
  27.  
  28. /* These are needed on various systems to expand REGISTER_U_ADDR.  */
  29. #ifndef USG
  30. #include <sys/dir.h>
  31. #include <sys/file.h>
  32. #include <sys/stat.h>
  33. #include <sys/user.h>
  34. #include "ptrace.h"
  35. #endif
  36. #include <sprite.h>
  37. #include <kernel/ds3100.md/machTypes.h>
  38.  
  39. /* Extract the register values out of the core file and store
  40.    them where `read_register' will find them.
  41.  
  42.    CORE_REG_SECT points to the register values themselves, read into memory.
  43.    CORE_REG_SIZE is the size of that area.
  44.    WHICH says which set of registers we are handling (0 = int, 2 = float
  45.          on machines where they are discontiguous).
  46.    REG_ADDR is the offset from u.u_ar0 to the register values relative to
  47.             core_reg_sect.  This is used with old-fashioned core files to
  48.         locate the registers in a large upage-plus-stack ".reg" section.
  49.         Original upage address X is at location core_reg_sect+x+reg_addr.
  50.  */
  51.  
  52. extern char registers[];
  53.  
  54. void
  55. fetch_core_registers (core_reg_sect, core_reg_size, which, reg_addr)
  56.      char *core_reg_sect;
  57.      unsigned core_reg_size;
  58.      int which;
  59.      unsigned reg_addr;
  60. {
  61.   register int regno;
  62.   register unsigned int addr;
  63.   int bad_reg = -1;
  64.   int i;
  65.  
  66. #define gregs ((Mach_RegState *)core_reg_sect)
  67.   bcopy (gregs->regs,
  68.      ®isters[REGISTER_BYTE (ZERO_REGNUM)],
  69.      32 * REGISTER_RAW_SIZE (ZERO_REGNUM));
  70.   bcopy (gregs->fpRegs,
  71.      ®isters[REGISTER_BYTE (FP0_REGNUM)],
  72.      32 * REGISTER_RAW_SIZE (ZERO_REGNUM));
  73.   
  74.   *(int *)®isters[REGISTER_BYTE (HI_REGNUM)] = gregs->mfhi;
  75.   *(int *)®isters[REGISTER_BYTE (LO_REGNUM)] = gregs->mflo;
  76.   *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = gregs->pc;
  77.   *(int *)®isters[REGISTER_BYTE (FCRCS_REGNUM)] = gregs->fpStatusReg;
  78.   *(int *)®isters[REGISTER_BYTE (FP_REGNUM)] = gregs->regs[29];
  79.   for (i = 0; i < NUM_REGS; i++) {
  80.     supply_register (i, ®isters[REGISTER_BYTE(i)]);
  81.   }
  82. }
  83.  
  84.  
  85. #ifdef REGISTER_U_ADDR
  86.  
  87. /* Return the address in the core dump or inferior of register REGNO.
  88.    BLOCKEND is the address of the end of the user structure.  */
  89.  
  90. unsigned int
  91. register_addr (regno, blockend)
  92.      int regno;
  93.      int blockend;
  94. {
  95.   int addr;
  96.  
  97.   if (regno < 0 || regno >= NUM_REGS)
  98.     error ("Invalid register number %d.", regno);
  99.  
  100.   REGISTER_U_ADDR (addr, blockend, regno);
  101.  
  102.   return addr;
  103. }
  104.  
  105. #endif /* REGISTER_U_ADDR */
  106.